package com.probiz.estore.common.model.catalog.base;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import com.probiz.estore.Constants;
import com.probiz.estore.common.model.catalog.ContentCategory;
import com.probiz.estore.common.model.content.RelatedContent;
import com.probiz.estore.core.model.BaseObject;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

/**
 * ContentCategory Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class ContentCategoryTbl extends BaseObject implements Serializable {

    protected Integer categoryId;
	protected Short categoryType;
	protected String categoryCode;
	protected String categoryName;
	protected String categoryDescription;
	protected String keywords;
	protected String metaDescription;
	protected String templatePath;
	protected Short depth;
	protected Short hasChildren;
	protected String parentPath;
	protected String categoryPath;
	protected String imageUrl;
	protected String linkUrl;
	protected Short linkTarget;
	protected String categoryContext;
	protected Integer sortOrder;
	protected Short status;
	protected String displayFlag;
	protected Integer itemCount;
	protected Integer activeItemCount;
	protected String hotWords;
	protected Integer createBy;
	protected Integer updateBy;
	protected java.util.Date createTime;
	protected java.util.Date updateTime;
	protected Integer version;
	protected ContentCategory parent;
	protected Set children = new java.util.HashSet();
	protected Set<RelatedContent> relatedContents = new HashSet<RelatedContent>(); //关联的文章

	/**
	 * Default Empty Constructor for class ContentCategory
	 */
	public ContentCategoryTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class ContentCategory
     * @param in_categoryId 目录id
	 */
	public ContentCategoryTbl (Integer in_categoryId) {
		this.setCategoryId(in_categoryId);
    }


    public ContentCategory getParent() {
        return parent;
    }

    public void setParent(ContentCategory parent) {
        this.parent = parent;
    }

    public Set getChildren() {
        return children;
    }

    public void setChildren(Set children) {
        this.children = children;
    }
    
    

    public Set<RelatedContent> getRelatedContents() {
		return relatedContents;
	}

	public void setRelatedContents(Set<RelatedContent> relatedContents) {
		this.relatedContents = relatedContents;
	}

	/**
	 * 	 * @return Integer
     * @hibernate.id column="categoryId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getCategoryId() {
		return this.categoryId;
	}
	
	/**
	 * Set the categoryId
	 */	
	public void setCategoryId(Integer aValue) {
		this.categoryId = aValue;
	}	

	/**
	 * 父目录id	 * @return Integer
	 */
	public Integer getParentId() {
		return this.getParent()==null?null:this.getParent().getCategoryId();
	}

	/**
	 * Set the parentId
	 */
	public void setParentId(Integer aValue) {
	    if (aValue==null) {
	    	parent = null;
	    } else {
	        parent = new ContentCategory(aValue);
	        parent.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}

	/**
	 * =1 文章栏目
            =2 单独页面
            =3 链接地址
            	 * @return Short
	 * @hibernate.property column="categoryType" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getCategoryType() {
		return this.categoryType;
	}
	
	/**
	 * Set the categoryType
	 */	
	public void setCategoryType(Short aValue) {
		this.categoryType = aValue;
	}	

	/**
	 * 目录编码，ak，主要用于url生成。	 * @return String
	 * @hibernate.property column="categoryCode" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getCategoryCode() {
		return this.categoryCode;
	}
	
	/**
	 * Set the categoryCode
	 * @spring.validator type="required"
	 */	
	public void setCategoryCode(String aValue) {
		this.categoryCode = aValue;
	}	

	/**
	 * 目录名称	 * @return String
	 * @hibernate.property column="categoryName" type="java.lang.String" length="128" not-null="true" unique="false"
	 */
	public String getCategoryName() {
		return this.categoryName;
	}
	
	/**
	 * Set the categoryName
	 * @spring.validator type="required"
	 */	
	public void setCategoryName(String aValue) {
		this.categoryName = aValue;
	}	

	/**
	 * 目录描述	 * @return String
	 * @hibernate.property column="categoryDescription" type="java.lang.String" length="65535" not-null="false" unique="false"
	 */
	public String getCategoryDescription() {
		return this.categoryDescription;
	}
	
	/**
	 * Set the categoryDescription
	 */	
	public void setCategoryDescription(String aValue) {
		this.categoryDescription = aValue;
	}	

	/**
	 * meta关键词	 * @return String
	 * @hibernate.property column="keywords" type="java.lang.String" length="256" not-null="false" unique="false"
	 */
	public String getKeywords() {
		return this.keywords;
	}
	
	/**
	 * Set the keywords
	 */	
	public void setKeywords(String aValue) {
		this.keywords = aValue;
	}	

	/**
	 * meta描述	 * @return String
	 * @hibernate.property column="metaDescription" type="java.lang.String" length="256" not-null="false" unique="false"
	 */
	public String getMetaDescription() {
		return this.metaDescription;
	}
	
	/**
	 * Set the metaDescription
	 */	
	public void setMetaDescription(String aValue) {
		this.metaDescription = aValue;
	}	

	/**
	 * 模板路径	 * @return String
	 * @hibernate.property column="templatePath" type="java.lang.String" length="128" not-null="false" unique="false"
	 */
	public String getTemplatePath() {
		return this.templatePath;
	}
	
	/**
	 * Set the templatePath
	 */	
	public void setTemplatePath(String aValue) {
		this.templatePath = aValue;
	}	

	/**
	 * 深度	 * @return Short
	 * @hibernate.property column="depth" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getDepth() {
		return this.depth;
	}
	
	/**
	 * Set the depth
	 */	
	public void setDepth(Short aValue) {
		this.depth = aValue;
	}	

	/**
	 * 是否有子目录 
            1=有
            0=无	 * @return Short
	 * @hibernate.property column="hasChildren" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getHasChildren() {
		return this.hasChildren;
	}
	
	/**
	 * Set the hasChildren
	 */	
	public void setHasChildren(Short aValue) {
		this.hasChildren = aValue;
	}	

	
	public String getParentPath() {
		return parentPath;
	}

	public void setParentPath(String parentPath) {
		this.parentPath = parentPath;
	}

	/**
	 * @hibernate.property column="categoryPath" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getCategoryPath() {
		return this.categoryPath;
	}
	
	/**
	 * Set the categoryPath
	 */	
	public void setCategoryPath(String aValue) {
		this.categoryPath = aValue;
	}	

	/**
	 * 图片url	 * @return String
	 * @hibernate.property column="imageUrl" type="java.lang.String" length="255" not-null="false" unique="false"
	 */
	public String getImageUrl() {
		return this.imageUrl;
	}
	
	/**
	 * Set the imageUrl
	 */	
	public void setImageUrl(String aValue) {
		this.imageUrl = aValue;
	}	

	/**
	 * 当categoryType=3 链接地址时候有用。存放链接地址	 * @return String
	 * @hibernate.property column="linkUrl" type="java.lang.String" length="255" not-null="false" unique="false"
	 */
	public String getLinkUrl() {
		return this.linkUrl;
	}
	
	/**
	 * Set the linkUrl
	 */	
	public void setLinkUrl(String aValue) {
		this.linkUrl = aValue;
	}	

	/**
	 * =0 链接在本页打开即_self
            =1 链接在新窗口打开，即_blank	 * @return Short
	 * @hibernate.property column="linkTarget" type="java.lang.Short" length="5" not-null="false" unique="false"
	 */
	public Short getLinkTarget() {
		return this.linkTarget;
	}
	
	/**
	 * Set the linkTarget
	 */	
	public void setLinkTarget(Short aValue) {
		this.linkTarget = aValue;
	}	

	/**
	 * 当categoryType=2 单独页面时候有用。存放页面内容。	 * @return String
	 * @hibernate.property column="categoryContext" type="java.lang.String" length="65535" not-null="false" unique="false"
	 */
	public String getCategoryContext() {
		return this.categoryContext;
	}
	
	/**
	 * Set the categoryContext
	 */	
	public void setCategoryContext(String aValue) {
		this.categoryContext = aValue;
	}	

	/**
	 * 排序值，一般值越小，越靠前	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 * @spring.validator type="required"
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * 0=前台不可见
            1=前台可见	 * @return Short
	 * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getStatus() {
		return this.status;
	}
	
	/**
	 * Set the status
	 * @spring.validator type="required"
	 */	
	public void setStatus(Short aValue) {
		this.status = aValue;
	}	

	/**
	 * 自定义的显示标志
            0=标签页
            1= new
            2= hot	 * @return String
	 * @hibernate.property column="displayFlag" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getDisplayFlag() {
		return this.displayFlag;
	}
	
	/**
	 * Set the displayFlag
	 */	
	public void setDisplayFlag(String aValue) {
		this.displayFlag = aValue;
	}	

	/**
	 * 目录下的文章的数量	 * @return Integer
	 * @hibernate.property column="itemCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getItemCount() {
		return this.itemCount;
	}
	
	/**
	 * Set the itemCount
	 */	
	public void setItemCount(Integer aValue) {
		this.itemCount = aValue;
	}	

	/**
	 * 前台目录下的可见文章的数量，即发布中文章数量	 * @return Integer
	 * @hibernate.property column="activeItemCount" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getActiveItemCount() {
		return this.activeItemCount;
	}
	
	/**
	 * Set the activeItemCount
	 */	
	public void setActiveItemCount(Integer aValue) {
		this.activeItemCount = aValue;
	}	

	
	public String getHotWords() {
		return hotWords;
	}

	public void setHotWords(String hotWords) {
		this.hotWords = hotWords;
	}

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="createBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getCreateBy() {
		return this.createBy;
	}
	
	/**
	 * Set the createBy
	 */	
	public void setCreateBy(Integer aValue) {
		this.createBy = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="updateBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getUpdateBy() {
		return this.updateBy;
	}
	
	/**
	 * Set the updateBy
	 */	
	public void setUpdateBy(Integer aValue) {
		this.updateBy = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 * @spring.validator type="required"
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 * @spring.validator type="required"
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	

	/**
	 * 	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof ContentCategoryTbl)) {
			return false;
		}
		ContentCategoryTbl rhs = (ContentCategoryTbl) object;
		return new EqualsBuilder()
				.append(this.categoryId, rhs.categoryId)
						.append(this.categoryType, rhs.categoryType)
				.append(this.categoryCode, rhs.categoryCode)
				.append(this.categoryName, rhs.categoryName)
				.append(this.categoryDescription, rhs.categoryDescription)
				.append(this.keywords, rhs.keywords)
				.append(this.metaDescription, rhs.metaDescription)
				.append(this.templatePath, rhs.templatePath)
				.append(this.depth, rhs.depth)
				.append(this.hasChildren, rhs.hasChildren)
				.append(this.categoryPath, rhs.categoryPath)
				.append(this.imageUrl, rhs.imageUrl)
				.append(this.linkUrl, rhs.linkUrl)
				.append(this.linkTarget, rhs.linkTarget)
				.append(this.categoryContext, rhs.categoryContext)
				.append(this.sortOrder, rhs.sortOrder)
				.append(this.status, rhs.status)
				.append(this.displayFlag, rhs.displayFlag)
				.append(this.itemCount, rhs.itemCount)
				.append(this.activeItemCount, rhs.activeItemCount)
				.append(this.createBy, rhs.createBy)
				.append(this.updateBy, rhs.updateBy)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.categoryId) 
						.append(this.categoryType) 
				.append(this.categoryCode) 
				.append(this.categoryName) 
				.append(this.categoryDescription) 
				.append(this.keywords) 
				.append(this.metaDescription) 
				.append(this.templatePath) 
				.append(this.depth) 
				.append(this.hasChildren) 
				.append(this.categoryPath) 
				.append(this.imageUrl) 
				.append(this.linkUrl) 
				.append(this.linkTarget) 
				.append(this.categoryContext) 
				.append(this.sortOrder) 
				.append(this.status) 
				.append(this.displayFlag) 
				.append(this.itemCount) 
				.append(this.activeItemCount) 
				.append(this.createBy) 
				.append(this.updateBy) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("categoryId", this.categoryId) 
						.append("categoryType", this.categoryType) 
				.append("categoryCode", this.categoryCode) 
				.append("categoryName", this.categoryName) 
				.append("categoryDescription", this.categoryDescription) 
				.append("keywords", this.keywords) 
				.append("metaDescription", this.metaDescription) 
				.append("templatePath", this.templatePath) 
				.append("depth", this.depth) 
				.append("hasChildren", this.hasChildren) 
				.append("categoryPath", this.categoryPath) 
				.append("imageUrl", this.imageUrl) 
				.append("linkUrl", this.linkUrl) 
				.append("linkTarget", this.linkTarget) 
				.append("categoryContext", this.categoryContext) 
				.append("sortOrder", this.sortOrder) 
				.append("status", this.status) 
				.append("displayFlag", this.displayFlag) 
				.append("itemCount", this.itemCount) 
				.append("activeItemCount", this.activeItemCount) 
				.append("createBy", this.createBy) 
				.append("updateBy", this.updateBy) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("version", this.version) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "categoryId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return categoryId;
	}

}